﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace CMS
{
    [Serializable]
    public class Hours
    {

        public long? ADM_ID { get; set; }
        public long? HRS_ID { get; set; }
        public long? USR_ID { get; set; }
        public string HRS_COMPANYNAME { get; set; }
        public DateTime? HRS_DATE { get; set; }
        public string HRS_WORKDAY { get; set; }
        public DateTime? HRS_PAYDAY { get; set; }
        public long? HRS_HOURS { get; set; }
        public string HRS_COMMENTS { get; set; }

        #region Constructors
        /// <summary>
        /// Creates a new instance of an Page object.
        /// </summary>
        public Hours() : this(null) { }

        /// <summary>
        /// Creates a new instance of an Page object.
        /// </summary>
        public Hours(long? id)
        {
            HRS_ID = id;
        }
        #endregion

        /// <summary>
        /// Returns a list of Pages.
        /// </summary>
        public static List<CMS.Hours> GetHours(Int64? ADM_ID, Int64? HRS_ID, Int64? USR_ID, string HRS_COMPANYNAME, DateTime? HRS_DATE, string HRS_WORKDAY, DateTime? HRS_PAYDAY, Int64? HRS_HOURS, String HRS_COMMENTS)
        {
            DataTable StoredProcedureTablePages = CMS.StoredProcedureValues.VW_Hours(ADM_ID, HRS_ID, USR_ID, HRS_COMPANYNAME, HRS_DATE, HRS_WORKDAY, HRS_PAYDAY, HRS_HOURS, HRS_COMMENTS);
            return GetListHour(StoredProcedureTablePages);
        }

        /// <summary>
        /// Converts a DataTable into a list of Pages.
        /// </summary>
        public static List<CMS.Hours> GetListHour(DataTable StoredProcedureTable)
        {
            List<CMS.Hours> OutHour = new List<CMS.Hours>();

            for (int i = 0; i < StoredProcedureTable.Rows.Count; i++)
            {
                CMS.Hours Hour = new CMS.Hours();
                DataRow Row = StoredProcedureTable.Rows[i];

                Hour.ADM_ID = Convert.ToInt64((Row["ADM_ID"]));
                Hour.HRS_ID = Convert.ToInt64((Row["HRS_ID"]));
                Hour.USR_ID = Convert.ToInt64((Row["USR_ID"]));
                Hour.HRS_COMPANYNAME = Row["HRS_COMPANYNAME"].ToString();
                Hour.HRS_DATE = CMS.Functions.NullableDatetime(Row["HRS_DATE"].ToString());
                Hour.HRS_WORKDAY = Row["HRS_WORKDAY"].ToString();
                Hour.HRS_PAYDAY = CMS.Functions.NullableDatetime(Row["HRS_PAYDAY"].ToString());
                Hour.HRS_HOURS = Convert.ToInt64(Row["HRS_HOURS"].ToString());
                Hour.HRS_COMMENTS = Row["HRS_COMMENTS"].ToString();
                OutHour.Add(Hour);
            }

            return OutHour;
        }
    }
}